-
Notifications
You must be signed in to change notification settings - Fork 6.1k
ProviderManager should have a varargs constructor #7806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @ThomasVitale! I've left some feedback inline.
@@ -96,7 +94,7 @@ public void authenticationSucceedsWhenFirstProviderReturnsNullButSecondAuthentic | |||
|
|||
@Test(expected = IllegalArgumentException.class) | |||
public void testStartupFailsIfProvidersNotSet() { | |||
new ProviderManager(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should still have a test for new ProviderManager((AuthenticationProvider) null)
and for new ProviderManager((List<AuthenticationProvider>) null)
.
The reason is that an application might do:
AuthenticationProvider provider = constructProvider();
return new ProviderManager(provider);
but constructProvider
returns null
.
I believe this also implies that the extra validation logic in checkState()
will turn out to be necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, thanks for the clarification. I have added the extra validation login in checkState()
and tests for both null scenarios.
@@ -189,7 +186,7 @@ public void parentAuthenticationIsUsedIfProvidersDontAuthenticate() { | |||
Authentication authReq = mock(Authentication.class); | |||
when(parent.authenticate(authReq)).thenReturn(authReq); | |||
ProviderManager mgr = new ProviderManager( | |||
Arrays.asList(mock(AuthenticationProvider.class)), parent); | |||
Collections.singletonList(mock(AuthenticationProvider.class)), parent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for these cleanup items, too. Will you please put them in a separate commit (same PR)? That is, any code changes that aren't directly related to the new constructor, let's separate them into their own commit. This simplifies maintenance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, now they are in their own commit.
@ThomasVitale Will you be able to apply the requested changes? |
@jzheaux I have just delivered the requested changes, sorry for the delay. Does it look ok now? |
- Added varargs constructor to ProviderManager. - Added check for null values in AuthenticationProvider list. - Updated ProviderManagerTests to test for null values using both constructors. Fixes gh-7713
Nice, @ThomasVitale! This is now merged into Also, I added a very slight polish via d22b476 |
Fixes gh-7713